package cn.yjh.controller;

import cn.yjh.entity.User;
import cn.yjh.mapper.UserMapper;
import org.springframework.beans.BeansException;
import org.springframework.beans.factory.BeanFactory;
import org.springframework.beans.factory.BeanFactoryAware;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RestController;

@RestController
public class UserController implements BeanFactoryAware {
    BeanFactory beanFactory;

    @GetMapping("/test")
    public User test(){
        UserMapper bean = beanFactory.getBean(UserMapper.class);
        User user = bean.selectByPrimaryKey("1");
        return user;
    }


    @Override
    public void setBeanFactory(BeanFactory beanFactory) throws BeansException {
        this.beanFactory = beanFactory;
    }
}
